<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>

<?php if (!empty($_COOKIE['Token'])):?>

    <form action="upload.php" method="post" enctype="multipart/form-data">
        上传头像<input type="file" name="file" id="imageHead">
        <img src="" id="showImage">
        <input type="submit">

    </form>
<?php else:echo '未登入'?>

<?php endif;?>



</body>
<script>
    var fileObj = document.getElementById('imageHead')
    function showImage() {
       var file = fileObj['files'];
       var URL = window.URL || window.webkitURL;
       var imgURL = URL.createObjectURL(file[0]);
       document.getElementById("showImage").src = imgURL;
    }
    onload=function () {
        console.log(fileObj);
        fileObj.onchange = showImage;
    }

</script>
</html>